package com.moji.controller.web;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.moji.common.base.ApiResult;
import com.moji.entity.MjAboutUs;
import com.moji.entity.MjAgreement;
import com.moji.entity.MjHomepage;
import com.moji.entity.MjProductDetail;
import com.moji.entity.dto.MjAgreementDto;
import com.moji.entity.dto.QueryAboutUsDto;
import com.moji.service.MjAboutUsService;
import com.moji.service.MjAgreementService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 协议相关表 前端控制器
 * </p>
 *
 * @author ccl
 * @since 2024-08-19
 */
@RestController
@RequestMapping("/web/mj_agreement")
@Api(tags = "网站相关协议管理", value = "网站相关协议管理")
public class MjAgreementController {
    @Resource
    private MjAgreementService mjAgreementService;

    @PostMapping("/queryAgreementByType")
    @ApiOperation(value = "获取协议,默认传Int类型的type，1-隐私协议 2-用户协议 3-服务说明 4-合同范本 5-注册协议  6-个人信息处理规则  7-对公账户信息，没有传type则返回全部", response = MjAgreement.class)
    public ApiResult<List<MjAgreement>> queryByPage(@RequestBody MjAgreementDto dto) {
        LambdaQueryWrapper<MjAgreement> queryWrapper = new LambdaQueryWrapper<>();
        if (dto.getType() != null) {
            queryWrapper.eq(MjAgreement::getType, dto.getType());
        }
        List<MjAgreement> list = mjAgreementService.list(queryWrapper);
        return ApiResult.ok(list);
    }


}

